package testUnit.empUnitTest;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Test;

import com.situ.staff.department.model.DepartmentModel;
import com.situ.staff.employee.dao.EmployeeDao;
import com.situ.staff.employee.model.EmployeeModel;

public class empTestUnit {
//	EmployeeModel model = new EmployeeModel();
	EmployeeDao dao = new EmployeeDao();
	@Test
	public void testInsert() {
		EmployeeModel model = new EmployeeModel("e07","软件开发三部", "111", "a03");
		try {
			dao.insert(model);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("插入成功");
	}
	
	@Test
	public void testdeleteByCode() {
		EmployeeModel model = new EmployeeModel("e05",null,null,null);
		try {
			dao.deleteByCode(model);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("删除完成");
	}
	
	@Test
	public void testdelete() {
		EmployeeModel model = new EmployeeModel(null,null,"111",null);
		try {
			dao.delete(model);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("删除成功2");
	}
	
	@Test
	public void testupdateAll() {
		EmployeeModel model = new EmployeeModel("e07","软件开发6部", "888", "a04");
		try {
			dao.updateAll(model);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("更新完成");
		
	}
	
	@Test
	public void testupdateActive() {
		EmployeeModel model = new EmployeeModel("e07",null, null, "a0000");
		try {
			dao.updateActive(model);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("更新完成");
	}
	
	@Test
	public void testselectList() {
		EmployeeModel model = new EmployeeModel("e07",null, null, null);
		List<EmployeeModel> list = new ArrayList<EmployeeModel>();
		try {
			list = dao.selectList(model);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(list.size());
	}
	@Test
	public void testselectModel() {
		EmployeeModel model = new EmployeeModel("e06",null, null, null);
//		List<EmployeeModel> list = new ArrayList<EmployeeModel>();
		EmployeeModel e1 = new EmployeeModel();
		try {
			e1 = dao.selectModel(model);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(e1.toString());
	}
}
